layui.use(['element', 'form', 'table', 'laydate'], function () {
    let $ = layui.$
        , element = layui.element
        , form = layui.form
        , laydate = layui.laydate
        , currCode = ''
        , filterType = 0
        , table = layui.table;

    // 渲染一次select
    form.render('select');
    form.render('checkbox');

    // if (window.chrome && window.chrome.webview) {
    //     if (navigator.userAgent.indexOf("xtd_client_v1.1") > 0) {
    //         $("#other3").show();
    //     }
    // }

    $(".fold-btn-wmm").click(function () {
        var type = $(this).attr("data-type");
        if (type === "close" || undefined === type) {
            $(this).attr("data-type", "open");
            $(this).parent().find(".drop-down-wmm").attr("style", "height:auto");
            $(this).html("收起<span class='layui-icon layui-icon-up'></span>");
        } else {
            $(this).attr("data-type", "close");
            $(this).parent().find(".drop-down-wmm").attr("style", "height:85px");
            $(this).html("更多<span class='layui-icon layui-icon-down'></span>");
        }
    });

    // 时间范围
    laydate.render({
        elem: '#stock-time'
        , type: 'time'
        , value: '09:20:00 - 09:25:00'
        , range: true
    });
    // 点击策略出结果
    $("input:radio[name='function']").on('change', function () {
        loadStockFilter();
    });

    // 监听Tab切换
    element.on('tab(filterType)', function (data) {
        filterType = data.index;
        if (0 === filterType || 1 === filterType || 2 === filterType) {
            $('#div-other3').show();
        } else if (3 === filterType || 4 === filterType) {
            $('#div-other3').hide()
        }
    });

    // 监听回车事件
    $('#stockCode').on('keydown', function (event) {
        if (event.keyCode === 13) {
            loadStockFilter();
            return false;
        }
    });

    // var loadStockOrder = function (code) {
    //     // if (code === currCode) {
    //     //     return;
    //     // }
    //     var field = {};
    //     field.stockTime = $('#stock-time').val();
    //     field.code = code ? code : "";
    //     field.filterType = filterType;
    //     field.stockCode = $('#stockCode').val();
    //     field.threshold = code ? $('#threshold').val() : "";
    //     field.other1 = code ? $('#other1').is(':checked') ? 1 : 0 : "";
    //     field.other2 = code ? $('#other2').is(':checked') ? 1 : 0 : "";
    //     field.other3 = code ? $('#other3').is(':checked') ? 1 : 0 : "";
    //     table.reload('LAY-manage-right', {
    //         where: field
    //     });
    // }

    var loadLocalStockFilter = function (field, message) {
        var data = JSON.parse(localStorage.getItem(message.key));
        if (1 !== parseInt(data.code) || '' === data.data) {
            localStorage.removeItem(message.key);
            layer.msg("请求失败, 请稍后重试");
            return;
        }
        var codeArry = data.data.filter(function (value, index, self) {
            return self.indexOf(value) === index;
        });
        field.stockCode = codeArry.join(',');
        table.reload('LAY-manage', {
            url: '/tdx/stockFilter/listNew',
            initSort: {
                field: 'diffAmount' //排序字段，对应 cols 设定的各字段名
                , type: 'desc' //排序方式  asc: 升序、desc: 降序、null: 默认排序
            },
            where: field
        });
    }

    var loadStockFilter = function () {
        // 获取当前时间
        const now = moment();
        const specificTime = moment().startOf('day').add({hours: 9, minutes: 26, seconds: 20});
        if (now.isBefore(specificTime)) {
            layer.msg("请于09:26:20之后选票");
            return;
        }

        currCode = '';
        var field = {};
        field.stockTime = $('#stock-time').val();
        field.filterType = filterType;
        field.funContent = Base64.encode($('#funContent').val());
        field.stockCode = $('#stockCode').val();
        field.function = $('input[name="function"]:checked').val();
        field.threshold = $('#threshold').val();
        field.other1 = $('#other1').is(':checked') ? 1 : 0;
        field.other2 = $('#other2').is(':checked') ? 1 : 0;
        field.other3 = $('#other3').is(':checked') ? 1 : 0;


        // todo 先本地获取问财数据,再去服务端处理逻辑数据
        if (window.chrome && window.chrome.webview && navigator.userAgent.indexOf("xtd_client_v1.1") > 0 && 4 !== field.filterType) {
            let loading = layer.msg('正在处理, 请稍等...', {icon: 16, shade: 0.3, time: 0});
            var message = {};
            message.op = "WenCai";
            message.type = 1;
            message.content = $('input[name="function"]:checked').attr("lay-data");
            // 1: AES加密 0:base64编码 不需要解密
            if (3 === field.filterType) {
                message.type = 0;
                message.content = field.funContent;
            }
            message.key = "xtd_" + moment().format('YYYYMMDD') + "_" + md5(message.content);
            if (1 === field.other3) {
                // 删除本地缓存
                localStorage.removeItem(message.key);
            }
            // console.log(JSON.stringify(message));
            if (!isUndefinedOrNull(localStorage.getItem(message.key))) {
                layer.close(loading);
                loadLocalStockFilter(field, message);
            } else {
                window.chrome.webview.postMessage(JSON.stringify(message));
                var interval = setInterval(function () {
                    if (isUndefinedOrNull(localStorage.getItem(message.key)))
                        return;
                    else
                        clearInterval(interval);
                    layer.close(loading);
                    loadLocalStockFilter(field, message);
                }, 200);
            }
        } else {
            //执行重载
            table.reload('LAY-manage', {
                initSort: {
                    field: 'diffAmount' //排序字段，对应 cols 设定的各字段名
                    , type: 'desc' //排序方式  asc: 升序、desc: 降序、null: 默认排序
                },
                where: field
            });
        }

        // table.reload('LAY-manage', {
        //     initSort: {
        //         field: 'diffAmount' //排序字段，对应 cols 设定的各字段名
        //         , type: 'desc' //排序方式  asc: 升序、desc: 降序、null: 默认排序
        //     },
        //     where: field
        // });
    }

    // $.ajax({
    //     type: "GET",
    //     url: "/tdx/function/selectOwnList",
    //     contentType: "application/json",
    //     success: function (json) {
    //         $.each(json.data, function (i, n) {
    //             1 == n.isShare ? $("#div-function-own").append("<label class=\"radio-item\"><input type=\"radio\" lay-filter=\"LAY-function-radio\" name=\"function\" value=\"" + n.id + "\" title=\"" + n.name + "\"><span> " + n.name + "<i class=\"icon-charge\"></i></span></label>")
    //                 : $("#div-function-own").append("<label class=\"radio-item\"><input type=\"radio\" lay-filter=\"LAY-function-radio\" name=\"function\" value=\"" + n.id + "\" title=\"" + n.name + "\"><span> " + n.name + "</span></label>");
    //         });
    //         // 修改了默认样式，不能再次渲染radio
    //         // form.render('radio');
    //         $("input:radio[name='function']").on('change', function () {
    //             loadStockFilter();
    //         });
    //     },
    //     error: function () {
    //         layer.msg("请求失败");
    //     }
    // });

    // $.ajax({
    //     type: "GET",
    //     url: "/tdx/function/selectUserList",
    //     contentType: "application/json",
    //     success: function (json) {
    //         $.each(json.data, function (i, n) {
    //             1 == n.isShare ? $("#div-function-user").append("<label class=\"radio-item\"><input type=\"radio\" lay-filter=\"LAY-function-radio\" name=\"function\" value=\"" + n.id + "\" title=\"" + n.name + "\"><span> " + n.name + "<i class=\"icon-charge\"></i></span></label>")
    //                 : $("#div-function-user").append("<label class=\"radio-item\"><input type=\"radio\" lay-filter=\"LAY-function-radio\" name=\"function\" value=\"" + n.id + "\" title=\"" + n.name + "\"><span> " + n.name + "</span></label>");
    //         });
    //         // 修改了默认样式，不能再次渲染radio
    //         // form.render('radio');
    //         $("input:radio[name='function']").on('change', function () {
    //             loadStockFilter();
    //         });
    //     },
    //     error: function () {
    //         layer.msg("请求失败");
    //     }
    // });

    var setBackgroundColor = function (data) {
        if (undefined === data) return;
        var that;
        $('.layui-form.layui-border-box.layui-table-view').each(function (ele) {
            if ('LAY-manage' === $(this).attr('lay-id')) {
                that = $(this);
            }
        });
        if (!that) return;
        data.forEach(function (item, index) {
            if (parseInt(item.diffAmount) > 10000000
                && parseInt(item.zhulijinge) > 10000000
                && parseInt(item.limitUpBuyAmount) > 1000000
                && parseFloat(item.openPer) >= 0) {
                // d.openPer && item.limitUpBuyAmount
                that.find(".layui-table-box tbody tr[data-index='" + index + "']").css("background-color", "#bfdfff");
            }

            if (parseInt(item.zdBuyAmount) > 50000000
                && parseInt(item.diffAmount) > parseInt(item.zdBuyAmount) * 0.8) {
                that.find(".layui-table-box tbody tr[data-index='" + index + "']").css("background-color", "#e7d4b1");
            }
            // if (item.condition2) {
            //     that.find(".layui-table-box tbody tr[data-index='" + index + "']").css("background-color", "#bfdfff");
            // }
            // if (item.condition3) {
            //     that.find(".layui-table-box tbody tr[data-index='" + index + "']").css("background-color", "#99c5fe");
            // }
            // if (item.limitUpBuy) {
            //     that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='code']").css("background-color", "#ae04b0");
            //     that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='code'] span").css("color", "#fff");
            //     that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='name']").css("background-color", "#ae04b0");
            //     that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='name'] span").css("color", "#fff");
            //     if (item.limitDownSell) {
            //         that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='code']").css("background-color", "#e8cab6");
            //         that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='code'] span").css("color", "#1c1d20");
            //         that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='name']").css("background-color", "#e8cab6");
            //         that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='name'] span").css("color", "#1c1d20");
            //         if (item.limitUpBuyCount > 1) {
            //             that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='code']").css("background-color", "#cd9b79");
            //             that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='code'] span").css("color", "#1c1d20");
            //             that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='name']").css("background-color", "#cd9b79");
            //             that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='name'] span").css("color", "#1c1d20");
            //         }
            //     }
            // }
        });
    }

    //数据表格
    // let loading = layer.msg("数据请求中...");
    table.render({
			elem: '#LAY-manage',
			url: 'http://localhost:5000/tdx/stockFilter/list',
			loading: true,
			// 全局定义常规单元格的最小宽度，layui 2.2.1 新增
			cellMinWidth: 10,
			// height: 'full-220', //高度最大化减去差值
			cols: [
				[
					{
						title: '代码',
						field: 'code',
						align: 'center',
						templet(d) {
							var diff = parseInt(d.buyAmount) - parseInt(d.sellAmount)
							var backgroundColor = 'rgba(255,255,255,0)'
							var fontColor = '#666'
							var zhuli_rule = false
							if (diff > 0) fontColor = '#f33333'
							if (diff < 0) fontColor = '#0aab62'
							if (d.condition1) (zhuli_rule = true), (fontColor = '#9f029c')
							if (d.limitUpBuy)
								(backgroundColor = '#cbace3'),
									zhuli_rule ? (fontColor = '#9f029c') : (fontColor = '#1c1d20')
							if (d.limitUpBuy && d.limitDownSell)
								(backgroundColor = '#e8cab6'),
									zhuli_rule ? (fontColor = '#9f029c') : (fontColor = '#1c1d20')
							if (d.limitUpBuy && d.limitDownSell && d.limitUpBuyCount > 1)
								(backgroundColor = '#cd9b79'),
									zhuli_rule ? (fontColor = '#9f029c') : (fontColor = '#1c1d20')
							return (
								'<div style="background-color:' +
								backgroundColor +
								' ;">'
									.concat('<span style="color: ' + fontColor + '">')
									.concat(d.code)
									.concat('</span>')
									// .concat(d.theme ? '&nbsp;<i class="layui-icon layui-icon-tips" lay-tips="' + d.theme + '"></i>' : '')
									.concat('</div>')
							)
							// var diff = parseInt(d.buyAmount) - parseInt(d.sellAmount);
							// return diff > 0 ? "<span class='limitUp'>" + d.code + "</span>" : "<span class='limitDown'>" + d.code + "</span>";
							// return diff > 0 ? "<a href=\"javascript:window.chrome.webview.postMessage('OpenStock " + d.code + "');\"><span class='limitUp'>" + d.code + "</span></a> "
							//     : "<a href=\"javascript:window.chrome.webview.postMessage('OpenStock " + d.code + "');\"><span class='limitDown'>" + d.code + "</span></a>";
						},
					},
					{
						title: '名称',
						field: 'name',
						align: 'center',
						templet(d) {
							var diff = parseInt(d.buyAmount) - parseInt(d.sellAmount)
							var backgroundColor = 'rgba(255,255,255,0)'
							var fontColor = '#666'
							var zhuli_rule = false
							if (diff > 0) fontColor = '#f33333'
							if (diff < 0) fontColor = '#0aab62'
							if (d.condition1) (zhuli_rule = true), (fontColor = '#9f029c')
							if (d.limitUpBuy)
								(backgroundColor = '#cbace3'),
									zhuli_rule ? (fontColor = '#9f029c') : (fontColor = '#1c1d20')
							if (d.limitUpBuy && d.limitDownSell)
								(backgroundColor = '#e8cab6'),
									zhuli_rule ? (fontColor = '#9f029c') : (fontColor = '#1c1d20')
							if (d.limitUpBuy && d.limitDownSell && d.limitUpBuyCount > 1)
								(backgroundColor = '#cd9b79'),
									zhuli_rule ? (fontColor = '#9f029c') : (fontColor = '#1c1d20')
							return (
								'<div style="background-color:' +
								backgroundColor +
								' ;">'
									.concat('<span ')
									// .concat(d.tractorOrder ? 'class="blinkwmm"' : '')
									// .concat(d.theme ? 'lay-tips="' + d.theme + '"' : '')
									.concat('style="color: ' + fontColor + '">')
									.concat(d.name)
									.concat('</span>')
									.concat('</div>')
							)
							// var diff = parseInt(d.buyAmount) - parseInt(d.sellAmount);
							// return diff > 0 ? "<span class='limitUp'>" + d.name + "</span>" : "<span class='limitDown'>" + d.name + "</span>";
							// return diff > 0 ? "<a href=\"javascript:window.chrome.webview.postMessage('OpenStock " + d.code + "');\"><span class='limitUp'>" + d.name + "</span></a> "
							//     : "<a href=\"javascript:window.chrome.webview.postMessage('OpenStock " + d.name + "');\"><span class='limitDown'>" + d.name + "</span></a>";
						},
					},
					{
						title: '竞涨幅',
						field: 'openPer',
						align: 'center',
						templet: function (d) {
							if (-999999 === d.openPer) {
								return '—'
							}
							return changeColor(d.openPer.toFixed(2))
						},
					},
					// {
					//     title: '撤买', field: 'cdBuyAmount', align: 'center', sort: true, templet: function (d) {
					//         return 0 === d.cdBuyAmount ? d.cdBuyAmount : "<span style='color: #9f029c'>" + Math.floor(d.cdBuyAmount / 10000) + "</span>";
					//     }
					// },
					{
						title: '动比',
						field: 'buyStrength',
						align: 'center',
						sort: true,
						templet: function (d) {
							return d.buyStrength
						},
					},
					{
						title: '主买',
						field: 'zdBuyAmount',
						align: 'center',
						sort: true,
						templet: function (d) {
							return 0 === d.zdBuyAmount
								? d.zdBuyAmount
								: "<span style='color: #f33333'>" +
										Math.floor(d.zdBuyAmount / 10000) +
										'</span>'
						},
					},
					// {
					//     title: '笼子价', field: 'buyPrice', align: 'center', templet: function (d) {
					//         return changeColor(d.buyPrice.toFixed(2));
					//         // var price = d.buyPrice.toFixed(2);
					//         // return price.toString().startsWith('-') ? "<a lay-event='buy' style='color: #0aab62;cursor: pointer;'>" + price + "</a>" : "<a lay-event='buy' style='color: #f33333;cursor: pointer;'>" + price + "</a>";
					//     }
					// },
					// {
					//     title: '卖额', field: 'sellAmount', align: 'center', sort: true, templet: function (d) {
					//         return 0 === d.sellAmount ? d.sellAmount : "<span class='limitDown'> -" + Math.floor(d.sellAmount / 10000) + "</span>";
					//     }
					// },
					// {
					//     title: '涨买', field: 'zhangTingBuyAmount', align: 'center', sort: true, templet: function (d) {
					//         return 0 === d.zhangTingBuyAmount ? d.zhangTingBuyAmount : "<span style='color: #1E9FFF'>" + Math.floor(d.zhangTingBuyAmount / 10000) + "</span>";
					//     }
					// },
					{
						title: '买额',
						field: 'buyAmount',
						align: 'center',
						sort: true,
						templet: function (d) {
							return 0 === d.buyAmount
								? d.buyAmount
								: "<span class='limitUp'>" +
										Math.floor(d.buyAmount / 10000) +
										'</span>'
						},
					},
					{
						title: '净额',
						field: 'diffAmount',
						align: 'center',
						sort: true,
						templet: function (d) {
							// var diff = parseInt(d.buyAmount) - parseInt(d.sellAmount);
							var diff = d.diffAmount
							return 0 === diff
								? diff
								: diff > 0
								? "<span class='limitUp'>" +
								  Math.floor(diff / 10000) +
								  '</span>'
								: "<span class='limitDown'>" +
								  Math.floor(diff / 10000) +
								  '</span>'
						},
					},
					{
						title: '主力净额',
						field: 'zhulijinge',
						align: 'center',
						sort: true,
						templet: function (d) {
							var zhulijinge = parseInt(d.zhulijinge)
							return 0 === zhulijinge
								? zhulijinge
								: zhulijinge > 0
								? "<span class='limitUp'>" +
								  Math.floor(zhulijinge / 10000) +
								  '</span>'
								: "<span class='limitDown'>" +
								  Math.floor(zhulijinge / 10000) +
								  '</span>'
						},
					},
					// {
					//     title: '强度', field: 'buyStrength', align: 'center', templet: function (d) {
					//         return d.buyStrength;
					//     }
					// }
					{
						title: '动能',
						field: 'limitUpBuyAmount',
						align: 'center',
						sort: true,
						templet: function (d) {
							return 0 === d.limitUpBuyAmount
								? d.limitUpBuyAmount
								: "<span style='color: #1E9FFF'>" +
										Math.floor(d.limitUpBuyAmount / 10000) +
										'</span>'
						},
					},
				],
			],
			page: false,
			done: function (res, curr, count) {
				// let stockCodeArray = '';
				// if (!res.data) {
				// loadStockOrder('');
				// return;
				// }
				setBackgroundColor(res.data)
				// stockCodeArray = res.data.map(item => item.code).join(",");
				// stockCodeArray = res.data[0]?.code;
				// loadStockOrder(stockCodeArray);
				// var that = this.elem.next();
				// res.data.forEach(function (item, index) {
				//     if (item.limitUpBuy) {
				//         that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='code']").css("background-color", "#ae04b0");
				//         that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='code'] span").css("color", "#fff");
				//         that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='name']").css("background-color", "#ae04b0");
				//         that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='name'] span").css("color", "#fff");
				//         if (item.limitDownSell) {
				//             that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='code']").css("background-color", "#e8cab6");
				//             that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='code'] span").css("color", "#1c1d20");
				//             that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='name']").css("background-color", "#e8cab6");
				//             that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='name'] span").css("color", "#1c1d20");
				//             if (item.limitUpBuyCount > 2) {
				//                 that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='code']").css("background-color", "#e8cab6");
				//                 that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='code'] span").css("color", "#1c1d20");
				//                 that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='name']").css("background-color", "#e8cab6");
				//                 that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='name'] span").css("color", "#1c1d20");
				//             }
				//         }
				//     }
				// });
				// $('#LAY-manage tbody tr').each(function (index, element) {
				//     debugger
				//     $(element).dblclick(function () {
				//         // 双击事件的处理函数
				//         console.log("双击事件")
				//     });
				// });
			},
		})

    // 监听搜索按钮
    form.on('submit(LAY-front-search)', function (data) {
        loadStockFilter();
    });
    // 监听行点击事件
    table.on("row(LAY-manage)", function (e) {
        currCode = e.data.code;
        // loadStockOrder(e.data.code);
        // 打开通达信客户端
        if (window.chrome && window.chrome.webview) {
            if (navigator.userAgent.indexOf("xtd_client_v1.1") > 0) {
                var message = {};
                message.op = "OpenStock";
                message.content = "" + e.data.code + "";
                message.type = -1;
                window.chrome.webview.postMessage(JSON.stringify(message));
            } else {
                window.chrome.webview.postMessage("OpenStock " + e.data.code);
            }
        }
        // table.reload('LAY-manage-right');
    });
    // 监听双击事件
    // table.on('rowDouble(LAY-manage)', function (obj) {
    // console.log(obj.tr) //得到当前行元素对象
    // console.log(obj.data) //得到当前行数据
    // });

    //
    table.on("tool(LAY-manage)", function (e) {
        // if ("buy" === e.event) {
        //     // console.log('笼子价')
        //     layui.stockData = e.data;
        //     layer.open({
        //         type: 2
        //         , title: '[' + e.data.name + '] 委托下单'
        //         , skin: 'layui-layer-rim'
        //         , content: '/modules/kpl/buyStock.html'
        //         , area: ['450px', '30%']
        //         , btn: ['确定', '取消']
        //         , yes: function (index, layero) {
        //             //点击确认触发 iframe 内容中的按钮提交
        //             var submit = layero.find('iframe').contents().find("#LAY-form-submit");
        //             submit.click();
        //         }
        //     });
        // }
    });

    // 表头排序
    table.on("sort(LAY-manage)", function (e) {
        //
        let tableData = layui.table.cache["LAY-manage"];
        // console.log(tableData);
        setBackgroundColor(tableData);
    });

    // table.render({
    //     elem: "#LAY-manage-right",
    //     url: '/kpl/stockOrder/list',
    //     size: 'sm',
    //     loading: true,
    //     // 全局定义常规单元格的最小宽度，layui 2.2.1 新增
    //     cellMinWidth: 10,
    //     height: 'full-100', //高度最大化减去差值
    //     cols: [[
    //         // {type: "checkbox"},
    //         {title: '时间', field: 'time', align: 'center'},
    //         {title: '代码', field: 'stockCode', align: 'center'},
    //         {title: '名称', field: 'stockName', align: 'center'},
    //         {
    //             title: '金额', field: 'amount', align: 'center', templet: function (d) {
    //                 return 2 === d.trade ? "<span>-" + Math.floor(d.amount / 10000) + "</span>" : "<span>" + Math.floor(d.amount / 10000) + "</span>";
    //             }
    //         },
    //         {title: '手数', field: 'vol', align: 'center',},
    //         {
    //             title: '买卖', field: 'trade', align: 'center', templet: function (d) {
    //                 return 2 === d.trade ? "<span class=''>卖</span>" : "<span class=''>买</span>";
    //             }
    //         },
    //         {
    //             title: '涨跌', field: 'limitUp', align: 'center', templet: function (d) {
    //                 if (0 !== d.limitUp) {
    //                     return 1 === d.limitUp ? "<span class=''>涨停</span>" : "<span class=''>跌停</span>";
    //                 } else {
    //                     return "";
    //                 }
    //             }
    //         }
    //         // {
    //         //     title: '价', field: 'price', align: 'center', templet: function (d) {
    //         //         return parseFloat(d.price).toFixed(2);
    //         //     }
    //         // }
    //     ]],
    //     page: false,
    //     done: function (res, curr, count) {
    //         // layer.close(loading);
    //         if (!res.data) return;
    //         var that = this.elem.next();
    //         res.data.forEach(function (item, index) {
    //             if ('' === currCode) return;
    //             if (2 === item.trade) {
    //                 // 卖
    //                 that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='time']").css("color", "#0aab62");
    //                 that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='stockCode']").css("color", "#0aab62");
    //                 that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='stockName']").css("color", "#0aab62");
    //                 that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='amount']").css("color", "#0aab62");
    //                 that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='vol']").css("color", "#0aab62");
    //                 that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='trade']").css("color", "#0aab62");
    //                 if (Math.floor(item.amount / 10000) > 300) {
    //                     that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='amount']").css("background-color", "#0aab62").css("color", "#fff")
    //                 } else {
    //                     that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='amount']").css("color", "#0aab62");
    //                 }
    //             } else {
    //                 that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='time']").css("color", "#f33333");
    //                 that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='stockCode']").css("color", "#f33333");
    //                 that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='stockName']").css("color", "#f33333");
    //                 that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='amount']").css("color", "#f33333");
    //                 that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='vol']").css("color", "#f33333");
    //                 that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='trade']").css("color", "#f33333");
    //                 if (Math.floor(item.amount / 10000) > 300) {
    //                     that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='amount']").css("background-color", "#f33333").css("color", "#fff");
    //                 } else {
    //                     that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='amount']").css("color", "#f33333");
    //                 }
    //             }
    //             // if (Math.floor(item.amount / 10000) > 300) {
    //             //     2 === item.trade ? that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='amount']").css("background-color", "#0aab62").css("color", "#fff")
    //             //         : that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='amount']").css("background-color", "#f33333").css("color", "#fff");
    //             // } else {
    //             //     that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='amount']").css("color", "#666");
    //             // }
    //             if (0 === item.limitUp) return;
    //             if (1 === item.limitUp) {
    //                 that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='limitUp']").css("background-color", "#f33333").css("color", "#fff");
    //                 // that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='price']").css("background-color", "#f33333").css("color", "#fff");
    //                 if (1 === item.trade)
    //                     that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='trade']").css("background-color", "#cbace3").css("color", "#9f029c");
    //             } else {
    //                 that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='limitUp']").css("background-color", "#499729").css("color", "#fff");
    //                 // that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='price']").css("background-color", "#499729").css("color", "#fff");
    //             }
    //             // 1 === item.limitUp ? (that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='limitUp']").css("background-color", "#f33333").css("color", "#fff"),
    //             //         that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='price']").css("background-color", "#f33333")).css("color", "#fff") :
    //             //     (that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='limitUp']").css("background-color", "#0aab62").css("color", "#fff"),
    //             //         that.find(".layui-table-box tbody tr[data-index='" + index + "'] td[data-field='price']").css("background-color", "#0aab62").css("color", "#fff"));
    //         });
    //     }
    // });
});